package com.group3.pojo.receive;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.group3.controller.Validated.Add;
import com.group3.controller.Validated.Update;
import com.group3.domain.Lesson;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.*;
import java.util.Date;

/**
 * LessonReceive
 *
 * @author HY
 * 2021/07/06 14:45
 **/

@Data
public class LessonReceive {

    @Min(value = 0, message = "课程安排id不能为空", groups = {Update.class})
    @ApiModelProperty(value = "课程安排id", required = true)
    private Integer lessonId;

    @NotEmpty(message = "课程名不能为空", groups = {Update.class})
    @ApiModelProperty(value = "课程名", required = true)
    private String lessonName;

    @NotNull(message = "课程开始日期不能为空", groups = {Add.class, Update.class})
    @Future(message = "课程开始时间必须为一个未来的时间", groups = {Add.class, Update.class})
    @ApiModelProperty(value = "上课时间（某一天）", required = true)
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date date;

    @NotNull(message = "课程开始时间不能为空", groups = {Add.class, Update.class})
    @ApiModelProperty(value = "应签到时间", required = true)
    @JsonFormat(pattern = "HH:mm", timezone = "GMT+8")
    private Date startTime;

    @NotNull(message = "课程结束时间不能为空", groups = {Add.class, Update.class})
    @ApiModelProperty(value = "应签退时间", required = true)
    @JsonFormat(pattern = "HH:mm", timezone = "GMT+8")
    private Date endTime;

    @NotEmpty(message = "教室名不能为空", groups = {Add.class, Update.class})
    @ApiModelProperty(value = "教室名", required = true)
    private String classRoom;

    @ApiModelProperty(value = "备注", required = true)
    private String remark;

    public Lesson getLesson(){
        Lesson lesson = new Lesson();

        lesson.setLessonId(this.lessonId);
        lesson.setLessonName(this.lessonName);
        lesson.setDate(this.date);
        lesson.setStartTime(this.startTime);
        lesson.setEndTime(this.endTime);
        lesson.setClassRoom(this.classRoom);
        lesson.setRemark(this.remark);

        return lesson;
    }

    public Lesson getLessonNotLessonId(){
        Lesson lesson = new Lesson();

//        lesson.setLessonId(this.lessonId);
        lesson.setLessonName(this.lessonName);
        lesson.setDate(this.date);
        lesson.setStartTime(this.startTime);
        lesson.setEndTime(this.endTime);
        lesson.setClassRoom(this.classRoom);
        lesson.setRemark(this.remark);

        return lesson;
    }
}
